#include "analogy_facts_searcher.hpp"

namespace mashine { namespace kb { namespace search {

AnalogyFactsSearchVisitor::AnalogyFactsSearchVisitor(std::string name)
		: SearchVisitor<mashine::kb::Literal, std::string>(new std::string(name))
{
}

std::vector<mashine::kb::Literal *> * AnalogyFactsSearchVisitor::search(mashine::kb::KnowledgeBase * kBase)
{
	if (criteria->compare("*"))
	{
		return kBase->getFacts();
	}

	std::vector<mashine::kb::Literal *> * result = new std::vector<mashine::kb::Literal *>();
	
	std::vector<mashine::kb::Literal *>::const_iterator i;
	for (i = kBase->getFacts()->begin(); i != kBase->getFacts()->end(); ++i)
	{
		if ( criteria->compare((*i)->getName()) )
		{
			result->push_back(*i);
		}
	}

	return result;
}

}}}